package com.vm.osm.business.dto.req.logic_equ;

import com.google.common.base.MoreObjects;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * 导入逻辑设备请求
 *
 * @author Xuerong Xue
 */
@Data
public class ImportLogicEquReq implements Serializable {
    @ApiModelProperty(value = "逻辑节点Id", required = true)
    @NotEmpty(message = "逻辑节点Id不能为空")
    private String logic_no_id;

    @ApiModelProperty(value = "设备编码")
    private String equ_code;

    @ApiModelProperty(value = "重新生成设备编码（0：否，1：是）")
    private Byte regen_equ_code;

    @ApiModelProperty(value = "设备类型（1：通用设备类型，2：专业设备类型）", required = true)
    @NotNull(message = "设备类型不能为空")
    private Byte equ_type;

    @ApiModelProperty(value = "设备类型Id", required = true)
    @NotNull(message = "设备类型Id不能为空")
    private String equ_type_id;

    @ApiModelProperty(value = "设备名称")
    private String equ_name;

    @ApiModelProperty("资源编码")
    private String resource_code;

    @ApiModelProperty("资源名称")
    private String resource_name;

    @ApiModelProperty(value = "设备品牌", required = true)
    @NotNull(message = "设备品牌不能为空")
    private String brand;

    @ApiModelProperty(value = "设备型号", required = true)
    @NotNull(message = "设备型号不能为空")
    private String model;

    @ApiModelProperty("规格")
    private String spec;

    @ApiModelProperty("制造厂家")
    private String manufactor_id;

    @ApiModelProperty("计量单位")
    private String measure_unit;

    @ApiModelProperty("项目Id")
    private String project_id;

    @ApiModelProperty("sn")
    private String sn;

    @ApiModelProperty("生产日期")
    private Date production_date;

    @ApiModelProperty("购买日期")
    private Date purchase_date;

    @ApiModelProperty(value = "保修期", required = true)
    @NotNull(message = "保修期不能为空")
    private Date maintenance_period;

    @ApiModelProperty("使用年限，单位：月")
    private Integer use_limit;

    @ApiModelProperty("原值")
    private String original_value;

    @ApiModelProperty("残值率")
    private BigDecimal scrap_ratio;

    @ApiModelProperty("服务商Id")
    private String service_provider_id;

    @ApiModelProperty("供应商Id")
    private String supplier_id;

    @ApiModelProperty("图片地址")
    private String img_url;

    @ApiModelProperty("地址")
    private String address;

    @ApiModelProperty("附件")
    private String attachment;

    @ApiModelProperty("备注")
    private String remark;

    @ApiModelProperty(value = "归属类型（1：自有设备，2：客户）", required = true)
    @NotNull(message = "设备归属不能为空")
    private Byte belong_type;

    @ApiModelProperty("设备归属者Id")
    private String belonger_id;

    @ApiModelProperty("自定义属性列表")
    private List<AttrItem> diy_attrs;

    @ApiModelProperty("配件列表")
    private List<PartItem> parts;

    @ApiModelProperty(value = "创建人Id", hidden = true)
    private String creator_id;

    @ApiModelProperty(value = "企业Id", hidden = true)
    private String enterprise_id;

    @ApiModelProperty(value = "会话Id", hidden = true)
    private String session_id;

    @Data
    public static class AttrItem implements Serializable {
        @ApiModelProperty("属性Id")
        private String attr_id;
        @ApiModelProperty("属性值")
        private String attr_val;

        @Override
        public String toString() {
            return MoreObjects.toStringHelper(this)
                    .add("attr_id", attr_id)
                    .add("attr_val", attr_val)
                    .toString();
        }
    }

    @Data
    public static class PartItem implements Serializable {
        @ApiModelProperty("配件Id，若为关联该字段必填，否则置空")
        private String id;
        @ApiModelProperty("品牌")
        private String brand;
        @ApiModelProperty("配件类型编号")
        private String equ_part_type_id;
        @ApiModelProperty("生产厂家")
        private String manufactor_id;
        @ApiModelProperty("计量单位")
        private String measure_unit;
        @ApiModelProperty("型号")
        private String model;
        @ApiModelProperty("原值")
        private String original_value;
        @ApiModelProperty("pn")
        private String pn;
        @ApiModelProperty("购买日期")
        private Integer purchase_date;
        @ApiModelProperty("sn")
        private String sn;
        @ApiModelProperty("规格")
        private String spec;
        @ApiModelProperty("规格")
        private String supplier_id;
        @ApiModelProperty("质保")
        private Integer warranty_date;

        @Override
        public String toString() {
            return MoreObjects.toStringHelper(this)
                    .add("id", id)
                    .add("brand", brand)
                    .add("equ_part_type_id", equ_part_type_id)
                    .add("manufactor_id", manufactor_id)
                    .add("measure_unit", measure_unit)
                    .add("model", model)
                    .add("original_value", original_value)
                    .add("pn", pn)
                    .add("purchase_date", purchase_date)
                    .add("sn", sn)
                    .add("spec", spec)
                    .add("supplier_id", supplier_id)
                    .add("warranty_date", warranty_date)
                    .toString();
        }
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("logic_no_id", logic_no_id)
                .add("equ_code", equ_code)
                .add("equ_type", equ_type)
                .add("equ_type_id", equ_type_id)
                .add("equ_name", equ_name)
                .add("resource_code", resource_code)
                .add("resource_name", resource_name)
                .add("brand", brand)
                .add("model", model)
                .add("spec", spec)
                .add("manufactor_id", manufactor_id)
                .add("measure_unit", measure_unit)
                .add("project_id", project_id)
                .add("sn", sn)
                .add("production_date", production_date)
                .add("purchase_date", purchase_date)
                .add("maintenance_period", maintenance_period)
                .add("use_limit", use_limit)
                .add("original_value", original_value)
                .add("scrap_ratio", scrap_ratio)
                .add("service_provider_id", service_provider_id)
                .add("supplier_id", supplier_id)
                .add("img_url", img_url)
                .add("address", address)
                .add("attachment", attachment)
                .add("remark", remark)
                .add("belong_type", belong_type)
                .add("belonger_id", belonger_id)
                .add("diy_attrs", null == diy_attrs ? null : Arrays.toString(diy_attrs.toArray()))
                .add("parts", null == parts ? null : Arrays.toString(parts.toArray()))
                .add("creator_id", creator_id)
                .add("enterprise_id", enterprise_id)
                .toString();
    }
}
